package com.ibsol.view
{
	import flash.display.Bitmap;
	
	import mx.containers.HBox;
	import mx.controls.Text;
	import mx.core.UIComponent;

	public class MapMarker extends UIComponent
	{
		[Embed(source='/assets/map/green_marker.png')]
		public var GreenMarker:Class;
		[Bindable]
		private var _label:String;
		[Bindable]
		private var _labelVisable:Boolean;
		public var hb:HBox;
		public var tooltip:Text;
		
		public function set label(value:String):void
		{
			this._label = value;
			tooltip.text = value;
		}
		
		public function get label():String
		{
			return this._label;
		}
		
		public function set labelVisable(value:Boolean):void
		{
			this._labelVisable = value;
			hb.visible = value;
		}
		
		public function get labelVisable():Boolean
		{
			return this._labelVisable;
		}
		
		public function MapMarker(label:String = "")
		{
			var m:Bitmap = new GreenMarker();
			this._label = label;
			this._labelVisable = false;
			this.addChild(m);
			drawLabel();
		}
		
		private function drawLabel():void
		{
			tooltip = new Text();
			tooltip.text = this._label;
			tooltip.setStyle("color",0xFFFFFF);
			hb = new HBox();
			hb.visible = _labelVisable;
			hb.width = 30;
			hb.height = 20;
			hb.x = -6;
			hb.y = -24;
			hb.setStyle("horizontalAlign", "center");
			hb.setStyle("backgroundAlpha",0.8);
			hb.setStyle("cornerRadius",5);
			hb.setStyle("borderSkin", TooltipSkin);
			hb.addChild(tooltip);
			this.addChild(hb);
		}
		
		
	}
}